<template>
  <view>
    <image class="bg-img" src="../../static/back.png"></image>
    <view class="user">
      <view class="user_head">
        <view class="user_head_img">
          <image src="https://cdn.uviewui.com/uview/swiper/swiper3.png" alt=""></image>
          <!-- <image v-else :src="ImageUrl + picture" alt=""></image> -->
        </view>
        <view class="user_head_right">
          <view class="user_head_right_text" @click="modify">{{ userInfo.username }}</view>
		  <view class="dlex">
          <view class="user_head_right_phone">
            <!-- <view class="user_head_right_phone_img">
            <image src="../../static/back_12.png" alt=""></image>
          </view> -->
            <button class="user_head_right_phone_text" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
              {{ isCoum == 1 ? '未绑定' : userInfo.phone }}
            </button>
          </view>
		  <view class="jifen">
		  	当前积分：{{userInfo.score}}
		  </view>
		  </view>
        </view>
      </view>
      <view class="user_subject">
        <view class="user_subject_article" v-for="(item, index) in listArray" @click="tinyAmount(index)" :key="index">
          <view class="user_subject_article_left">
            <view class="user_subject_article_left_img">
              <image :src="item.lable"></image>
            </view>
            <view class="user_subject_article_left_text">{{ item.value }}</view>
          </view>
          <view class="user_subject_article_right">
            <image src="../../static/back_4.png"></image>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import { loginPhone, sysUserName } from "@/api/index.js";
export default {
  data() {
    return {
      listArray: [
        {
          value: "兑换记录",
          lable: "../../static/back_6.png",
        },
        // {
        //   value: "审核",
        //   lable: "../../static/back_7.png",
        // },
        // {
        //   value: "联系客服",
        //   lable: "../../static/back_8.png",
        // },
      ],
      userInfo: {},
      isCoum: 1
    };
  },
  onShow: function() {
    this.sysUserName()
  },
  methods: {
    /**点击列表 */
    tinyAmount(e) {
      if (e == 0) {
        //积分管理
        uni.navigateTo({
          url: "../../packageA/exchange/exchange",
        });
      } 
      // else if (e == 1) {
      //   //审核
      //   uni.navigateTo({
      //     url: "../../packageA/audit/audit",
      //   });
      // }
    },
	/**修改名称*/
	modify(){
		uni.navigateTo({
		  url: "../../packageA/management/management",
		});
	},
    /**绑定手机号码 */
    getPhoneNumber(e) {
      console.log(e.detail.code);
      if (e.detail.errMsg === "getPhoneNumber:ok") {
        loginPhone({
          code: e.detail.code
        }).then((res) => {
          if (res.code == 0) {
			this.userInfo = res.data
            this.isCoum = 0
            this.sysUserName()
          }
        })
      }
    },
    sysUserName() {
      sysUserName().then((res) => {
        if (res.code == 0) {
          this.userInfo = res.data
		  if (this.userInfo.phone != '') {
		  	this.isCoum = 0
		  } 
        }
      })
    }
  },
};
</script>

<style lang="scss" scoped>
.bg-img {
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  z-index: -1;
}

.user {
  &_head {
    margin: 51rpx 27rpx 47rpx 31rpx;
    height: 106rpx;
    display: flex;

    &_img {
      height: 106rpx;
      width: 106rpx;

      image {
        border-radius: 50%;
        width: 100%;
        height: 100%;
      }
    }

    &_right {
      margin-left: 28rpx;
      line-height: 59rpx;

      &_text {
        font-size: 40rpx;
        font-weight: bold;
        color: #ffffff;

        margin-bottom: 8rpx;
      }

      &_phone {
        width: 84px;
        display: flex;
        background-image: linear-gradient(to right, #dbe6ff, #f3deff);
        border-radius: 14rpx;
        height: 54rpx;
		text-align: center;
        &_img {
          // line-height: 54rpx;
          width: 30rpx;
          height: 30rpx;
          margin: 0 10rpx;

          image {
            width: 100%;
            height: 100%;
          }
        }

        &_text {
          font-size: 25rpx;
          font-weight: bold;
          line-height: 51rpx;
          color: #000;
          padding-left: 0px;
          background-color: transparent;
          border-color: transparent;
        }

        &_text::after {
          border: none;
        }
      }
    }
  }

  &_subject {
    width: 654rpx;
    height: 85vh;
    background: #ffffff;
    box-shadow: 0rpx 3rpx 8rpx rgba(0, 0, 0, 0.12);
    border-radius: 24rpx 24rpx 0rpx 0rpx;
    padding: 0px 48rpx 0 48rpx;

    &_article {
      display: flex;
      justify-content: space-between;
      padding: 34rpx 0;
      border-bottom: 1px solid #e3e3e3;

      &_left {
        display: flex;

        &_img {
          width: 64rpx;
          height: 64rpx;

          image {
            width: 100%;
            height: 100%;
          }
        }

        &_text {
          margin-left: 20rpx;
          font-size: 30rpx;
          font-weight: 400;
          color: #121212;
          line-height: 66rpx;
        }
      }

      &_right {
        width: 24rpx;
        height: 24rpx;
        line-height: 66rpx;

        image {
          width: 100%;
          height: 100%;
        }
      }
    }
  }
}
.dlex{
	display: flex;
}
.jifen{
	    margin-left: 15px;
	    color: #fff;
}
</style>
